package com.iMusic.presentationLayer;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.iMusic.businessLogicLayer.CustomerReport;
import com.iMusic.businessLogicLayer.FinancialReports;

public class GenerateFinancialReports extends HttpServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String redirection = "adminFS.jsp?action=FinancialReporting";
		HttpSession session = request.getSession();

		String startDate = request.getParameter("StartDate");
		String endDate = request.getParameter("EndDate");
		
		FinancialReports finReport = new FinancialReports(startDate, endDate);
		
		try {
			finReport.generateAccounting();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		session.setAttribute("FinancialReports", finReport);

		response.sendRedirect(redirection);
	}
}
